<script setup>
import {
    Edit,
    Delete
} from '@element-plus/icons-vue'
import { ref } from 'vue'
//声明异步函数
import {articleCategoryListService} from '@/api/article.js'
const categorys = ref([])
const articleCategoryList = async()=>{
    let result=articleCategoryListService();
    categorys.value=result.data;
}
articleCategoryList();
</script>
<template>
    <el-card class="page-container">
        <template #header>
            <div class="header">
                <span>文章分类</span>
                <div class="extra">
                    <el-button type="primary">添加分类</el-button>
                </div>
            </div>
        </template>
        <el-table :data="categorys" style="width: 100%">
            <el-table-column label="序号" width="100" type="index"> </el-table-column>
            <el-table-column label="名称" prop="name"></el-table-column>
            <el-table-column label="图片" prop="image">
                <template #default="{row }">
                    <img :src="row.image" style="width: 50px; height: 50px;" />
                </template>
            </el-table-column>
            <el-table-column label="区域" prop="district"></el-table-column>
            <el-table-column label="类型" prop="type"></el-table-column>
            <el-table-column label="操作" width="200">
                <template #default="{ row }">
                    <el-button :icon="Edit" circle plain type="primary" @click="editCategory(row)">编辑</el-button>
                    <el-button :icon="Delete" circle plain type="danger" @click="deleteCategory(row)">删除</el-button>
                </template>
            </el-table-column>
            <template #empty>
                <el-empty description="没有数据" />
            </template>
        </el-table>
    </el-card>
</template>

<style lang="scss" scoped>
.page-container {
    min-height: 100%;
    box-sizing: border-box;

    .header {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
}
</style>